package com.hotelvip.controller;

import com.hotelvip.common.utils.JSONResult;
import com.hotelvip.dto.VipCardTdo;
import com.hotelvip.entity.VItem;
import com.hotelvip.service.VipCardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 会员Vip卡套餐模块
 * @author Lzh
 * @date 2021-1-29 16:35:16
 */
@RestController
@RequestMapping("/vipCard")
@Api(basePath = "/vipCard",tags = "Vip卡套餐模块")
public class VipCardController {

    @Autowired
    private VipCardService vipCardService;
    /**
     *
     * @param vipCardTdo
     * @return ok
     */
    @ApiOperation(value = "Vip卡新增",httpMethod = "POST")
    @PostMapping("/addVipCard")
    public JSONResult addVipCard(@RequestBody VipCardTdo vipCardTdo){
        vipCardService.addVipCard(vipCardTdo);
        return JSONResult.ok();
    }

    /**
     * 查询所有非赠送的会员卡类型
     */
    @ApiOperation(value = "查询所有会员卡类型",httpMethod = "GET")
    @GetMapping("/findAllVipCard/{current}/{size}/{vipType}")
    public JSONResult selectAllVipCard(@PathVariable("current") Long current
            , @PathVariable("size") Long size
            , @ApiParam(value = "0为正常卡、1为赠送卡、2为所有卡") @PathVariable("vipType") Integer vipType) {
        return JSONResult.ok(vipCardService.selectAllVipCard(current, size,vipType));
    }

    /**
     * 赠送卡不返现,不转让,不置换
     */
    @ApiOperation(value = "查询所有赠送卡",httpMethod = "GET")
    @GetMapping("/fundGiveAwayVipCard")
    public JSONResult fundGiveAwayVipCard() {
        return JSONResult.ok(vipCardService.selectGiveAwayVipCard());
    }
    @ApiOperation(value = "删除会员卡",httpMethod = "DELETE")
    @DeleteMapping("/deleteVipCard")
    public JSONResult deleteVipCardById(Long id) {
        vipCardService.deleteVipCard(id);
        return JSONResult.ok();
    }
    /**
     *
     * @return
     */
    @ApiOperation(value = "修改Vip卡套餐内的信息",httpMethod = "PUT")
    @PutMapping("updateVipCard")
    public JSONResult updateVipCard(@RequestBody VipCardTdo vipCardTdo) {
        vipCardService.updateVipCard(vipCardTdo);
        return JSONResult.ok();
    }


    /**
     *
     * @param id 会员套餐卡id
     * @return 会员卡详细信息
     */
    @ApiOperation(value = "查询当前会员卡的详细信息",httpMethod = "GET")
    @GetMapping("selectVipCardById/{id}")
    public JSONResult selectVipCardById(@PathVariable("id")Long id) {
        return JSONResult.ok(vipCardService.selectVipCardById(id));
        //TODO 现在不知道需要显示什么数据
    }


    /**
     * 新增/修改权益
     * @param vItem 权益信息
     * @return ok
     */
    @ApiOperation(value = "修改权益信息",httpMethod = "POST")
    @PostMapping("updateOrSaveVItem")
    public JSONResult updateOrSaveVItem(@RequestBody VItem vItem) {
        vipCardService.updateOrSaveVItem(vItem);
        return JSONResult.ok();
    }



    /**
     * 删除权益信息(暂时不用)
     */
/*
    @ApiOperation(value = "按照权益id删除权益",httpMethod = "DELETE")
    @DeleteMapping("deleteVItemById/{id}")
    public JSONResult deleteVItemById(@PathVariable("id")Long id) {
        vipCardService.deleteVItem(id);
        return JSONResult.ok();
    }
*/

    /**
     *
     * @param vItem 权益信息
     * @return ok
     */
    @ApiOperation(value = "添加新的权益信息",httpMethod = "POST")
    @PostMapping("insertVItem")
    public JSONResult insertVItem(@RequestBody VItem vItem) {
        vipCardService.insertVItem(vItem);
        return JSONResult.ok();
    }
}
